package com.jzr.bedside.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jzr.bedside.db1.model.TFee;
import com.jzr.bedside.db1.service.TFeeService;
import com.jzr.common.entity.vo.Result;
import com.jzr.common.util.U;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "病人费用接口")
@RestController
@RequestMapping("/api/fee")
public class FeeController {
    @Autowired
    private TFeeService feeService;

    @ApiOperation("获取费用列表接口")
    @GetMapping("/get")
    public Result<List<TFee>> get(@ApiParam("查询费用参数") TFee record){
        if(record == null){
            return Result.fail("参数不能为空");
        }
        if(U.isBlank(record.getPatientCode())){
            return Result.fail("patientCode不能为空");
        }
        QueryWrapper<TFee> qw = new QueryWrapper<>();
        qw.orderByAsc("patient_code","inv_no","item_code");

        qw.eq(TFee.PatientCode_,record.getPatientCode());

        if(U.isNotBlank(record.getInvNo())){
            qw.eq(TFee.InvNo_,record.getInvNo());
        }

        List<TFee> list = feeService.list(qw);
        return Result.success("成功",list,list==null ? 0:list.size());
    }

}
